Skip to content

Conversation

GuillaumeGomez
Copy link
Member

Follow-up of #142601.

Tested it locally with: BASE_COMMIT=1bb335244c311a07cee165c28c553c869e6f64a9 src/ci/docker/host-x86_64/mingw-check-1/validate-rustdoc-json-format-version-update.sh (where BASE_COMMIT value was the commit before I made a wrong change with the FORMAT_VERSION update).

This is a first version. I plan to send a follow-up to also ensure that FORMAT_VERSION is updated if any code change is done in rustdoc-json-types. For that I just need to check that a line not starting with / and not an empty line was updated. Fun times with grep ahead. :')

cc @aDotInTheVoid
r? @nnethercote

@rustbot
Copy link
Collaborator

rustbot commented Jun 18, 2025

nnethercote is not on the review rotation at the moment.
They may take a while to respond.

@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. labels Jun 18, 2025
@Kobzol
Copy link
Member

Kobzol commented Jun 18, 2025

Could this be a tidy check instead? It's better to have these things in one centralized place in Rust, rather than scattered around in random bash scripts.

@GuillaumeGomez
Copy link
Member Author

I guess? Didn't even realize that I could do the same in rust much more easily. ^^'

@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez GuillaumeGomez force-pushed the check-format-version-update branch from 23e5243 to 5d9e058 Compare June 18, 2025 15:29
@rustbot rustbot added A-tidy Area: The tidy tool T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jun 18, 2025
@GuillaumeGomez
Copy link
Member Author

Moved it to tidy. I'll do the same with the other bash tidy check I added.

@GuillaumeGomez
Copy link
Member Author

Oh also:

r? @Kobzol

Copy link
Member

@Kobzol Kobzol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it could also work locally, but it's always a PITA to figure out a diff vs master, so this is fine. Could you please try to break the CI job in this PR to see if it works on PR CI?

@GuillaumeGomez GuillaumeGomez force-pushed the check-format-version-update branch from 5d9e058 to 43d18cf Compare June 19, 2025 11:22
@rustbot rustbot added the A-rustdoc-json Area: Rustdoc JSON backend label Jun 19, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jun 19, 2025

rustdoc-json-types is a public (although nightly-only) API. If possible, consider changing src/librustdoc/json/conversions.rs; otherwise, make sure you bump the FORMAT_VERSION constant.

cc @CraftSpider, @aDotInTheVoid, @Enselic, @obi1kenobi

@Kobzol
Copy link
Member

Kobzol commented Jun 19, 2025

2025-06-19T11:27:57.5354234Z [TIMING] core::build_steps::tool::Tidy { compiler: Compiler { stage: 0, host: x86_64-unknown-linux-gnu, forced_compiler: false }, target: x86_64-unknown-linux-gnu } -- 0.000
2025-06-19T11:27:57.5354975Z fmt check
2025-06-19T11:28:04.5397272Z fmt: checked 6074 files
2025-06-19T11:28:05.0397217Z tidy check
2025-06-19T11:28:24.2535092Z Running eslint on rustdoc JS files
2025-06-19T11:28:29.4054908Z tidy: Skipping binary file check, read-only filesystem
2025-06-19T11:28:36.0337263Z removing old virtual environment
2025-06-19T11:28:36.0359346Z creating virtual environment at '/checkout/obj/build/venv' using 'python3.10' and 'venv'
2025-06-19T11:28:36.0843019Z creating virtual environment at '/checkout/obj/build/venv' using 'python3.10' and 'virtualenv'
2025-06-19T11:28:37.6050421Z Requirement already satisfied: pip in ./build/venv/lib/python3.10/site-packages (25.1.1)
2025-06-19T11:28:38.8879878Z linting python files
2025-06-19T11:28:39.0477863Z All checks passed!
2025-06-19T11:28:39.0488259Z checking python file formatting
2025-06-19T11:28:39.1812151Z 28 files already formatted
2025-06-19T11:28:39.1822499Z checking C++ file formatting
2025-06-19T11:28:41.0313008Z x.py completions check

Looks like the check didn't run, hmm. Probably adding some logging before the return; statements would be useful, to figure out why. And also printing the output of git diff.

@GuillaumeGomez
Copy link
Member Author

It's because BASE_COMMIT is not set in tidy. Changing that.

@GuillaumeGomez GuillaumeGomez force-pushed the check-format-version-update branch from 76cea70 to 122cf96 Compare June 19, 2025 15:04
@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez GuillaumeGomez force-pushed the check-format-version-update branch from 122cf96 to c352ab5 Compare June 19, 2025 15:12
Copy link
Member

@aDotInTheVoid aDotInTheVoid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conceptually this change makes sense and is good.

This is a first version. I plan to send a follow-up to also ensure that FORMAT_VERSION is updated if any code change is done in rustdoc-json-types. For that I just need to check that a line not starting with / and not an empty line was updated.

I worry that this could still have false positives. E.g. #142642 touches non-comments in src/rustdoc-json-types, but doesn't need to bump the FORMAT_VERSION

@@ -38,7 +38,7 @@ pub type FxHashMap<K, V> = HashMap<K, V>; // re-export for use in src/librustdoc
// are deliberately not in a doc comment, because they need not be in public docs.)
//
// Latest feature: Pretty printing of inline attributes changed
pub const FORMAT_VERSION: u32 = 48;
pub const FORMAT_VERSION: u32 = 49;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This 48->49 change should be reverted before merging.

@GuillaumeGomez GuillaumeGomez force-pushed the check-format-version-update branch from c352ab5 to 5c4daf1 Compare June 20, 2025 11:49
@GuillaumeGomez GuillaumeGomez force-pushed the check-format-version-update branch from 5c4daf1 to 9cccf1e Compare June 20, 2025 12:50
@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez GuillaumeGomez force-pushed the check-format-version-update branch from aa1b8eb to 6367694 Compare June 20, 2025 13:49
@GuillaumeGomez
Copy link
Member Author

Check is failing as expected so removed the failing commit. Should be now.

Copy link
Member

@Kobzol Kobzol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two nits, otherwise looks good.

) {
Ok(Some(commit)) => commit,
Ok(None) => {
*bad = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please only set *bad here and below on CI (if CiEnv::current() is CI)? For some users get_closest_upstream_commit might not return anything, e.g. if they have a shallow checkout. Yes, this is all sadly very annoying.. :D

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I keep discovering new cases to handle 😆

*bad = true;
if latest_feature_comment_updated {
eprintln!(
"error: `Latest feature` comment was updated whereas `FORMAT_VERSION` wasn't"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although people will probably be able to infer it, I think it would be nice if the error message contained the filename that should be fixed, otherwise the error can be quite opaque.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@GuillaumeGomez
Copy link
Member Author

Applied your suggestions. Thanks a lot, learned a lot with this PR!

@rust-log-analyzer

This comment has been minimized.

Only emit git errors if we are in CI environment
@GuillaumeGomez GuillaumeGomez force-pushed the check-format-version-update branch from 989fd9d to 0fc9507 Compare June 20, 2025 14:22
@Kobzol
Copy link
Member

Kobzol commented Jun 20, 2025

Yeah, there's really a lot to learn here 😆 Thanks!

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Jun 20, 2025

📌 Commit 0fc9507 has been approved by Kobzol

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 20, 2025
bors added a commit that referenced this pull request Jun 21, 2025
Rollup of 8 pull requests

Successful merges:

 - #142384 (Bringing `rustc_rayon_core` in tree as `rustc_thread_pool`)
 - #142476 (Insert parentheses around binary operation with attribute)
 - #142485 (Marks ADT live if it appears in pattern)
 - #142571 (Reason about borrowed classes in CopyProp.)
 - #142677 (Add CI check to ensure that rustdoc JSON `FORMAT_VERSION` is correctly updated)
 - #142716 (Adjust `with_generic_param_rib`.)
 - #142756 (Make `Clone` a `const_trait`)
 - #142765 (rustc_target: document public AbiMap-related fn and variants)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit cd85b9d into rust-lang:master Jun 21, 2025
10 checks passed
@rustbot rustbot added this to the 1.89.0 milestone Jun 21, 2025
rust-timer added a commit that referenced this pull request Jun 21, 2025
Rollup merge of #142677 - GuillaumeGomez:check-format-version-update, r=Kobzol

Add CI check to ensure that rustdoc JSON `FORMAT_VERSION` is correctly updated

Follow-up of #142601.

Tested it locally with: `BASE_COMMIT=1bb335244c311a07cee165c28c553c869e6f64a9 src/ci/docker/host-x86_64/mingw-check-1/validate-rustdoc-json-format-version-update.sh` (where `BASE_COMMIT` value was the commit before I made a wrong change with the `FORMAT_VERSION` update).

This is a first version. I plan to send a follow-up to also ensure that `FORMAT_VERSION` is updated if any code change is done in `rustdoc-json-types`. For that I just need to check that a line not starting with `/` and not an empty line was updated. Fun times with `grep` ahead. :')

cc `@aDotInTheVoid`
r? `@nnethercote`
@GuillaumeGomez GuillaumeGomez deleted the check-format-version-update branch June 21, 2025 13:22
jhpratt added a commit to jhpratt/rust that referenced this pull request Jun 22, 2025
…version-update, r=Kobzol

Check rustdoc-json-types FORMAT_VERSION is correctly updated

Follow-up of rust-lang#142677.

`@nnethercote` suggested that we should also ensure that the `FORMAT_VERSION` was only increased by 1 and we should check for it, this PR does it.

cc `@aDotInTheVoid`
r? ghost
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jun 23, 2025
…version-update, r=Kobzol

Check rustdoc-json-types FORMAT_VERSION is correctly updated

Follow-up of rust-lang#142677.

``@nnethercote`` suggested that we should also ensure that the `FORMAT_VERSION` was only increased by 1 and we should check for it, this PR does it.

cc ``@aDotInTheVoid``
r? ghost
rust-timer added a commit that referenced this pull request Jun 23, 2025
Rollup merge of #142875 - GuillaumeGomez:rustdoc-json-types-version-update, r=Kobzol

Check rustdoc-json-types FORMAT_VERSION is correctly updated

Follow-up of #142677.

``@nnethercote`` suggested that we should also ensure that the `FORMAT_VERSION` was only increased by 1 and we should check for it, this PR does it.

cc ``@aDotInTheVoid``
r? ghost
workingjubilee added a commit to workingjubilee/rustc that referenced this pull request Jun 23, 2025
…oval, r=Kobzol

Move error code explanation removal check into tidy

Follow-up of rust-lang#142677.

This PR replaces a shell script with rust code.

r? ghost
rust-timer added a commit that referenced this pull request Jun 24, 2025
Rollup merge of #142827 - GuillaumeGomez:tidy-error-code-removal, r=Kobzol

Move error code explanation removal check into tidy

Follow-up of #142677.

This PR replaces a shell script with rust code.

r? ghost
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Jun 26, 2025
…pdate, r=Kobzol

Check rustdoc-json-types FORMAT_VERSION is correctly updated

Follow-up of rust-lang/rust#142677.

``@nnethercote`` suggested that we should also ensure that the `FORMAT_VERSION` was only increased by 1 and we should check for it, this PR does it.

cc ``@aDotInTheVoid``
r? ghost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-json Area: Rustdoc JSON backend A-testsuite Area: The testsuite used to check the correctness of rustc A-tidy Area: The tidy tool S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants